Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk update/create Resources from Excel #11

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

gbern-tg
Copy link
Contributor

@gbern-tg gbern-tg commented Dec 11, 2023

Bulk update/create Resources from Excel

Functionality: a means to allow admins to bulk update/create resources from excel.

Example:

  1. ./tg export - by default, exports the admin's tenant into an xlsx file
  2. The admin can go in and adjust most (see limitations below) cells for bulk configuration changes, and save the file.
  3. ./tg import -f <xlsx-file> - will import the saved configuration changes and attempt to either (a) update the existing resource or (b) create a new resource

Explanation of changes:

TwingateApiClient.mjs:

  • Expanded resource fields - although groups and serviceAccounts is now deprecated for the access connection, there doesn't seem to be consistency across the API so I left as is (FRs that need to be requested below).
  • Updated createResource() for expanded functionality with the mutation
  • Created updateResource() to allow bulk update functionality with the mutation

smallUtilFuncs.mjs:

  • readerFromStreamReader seems to be deprecated, temporarily updated module to the last working version (not familiar enough with a path forward - @chenbishop?)
  • updated genFileNameFromNetworkName() to accommodate new output folder so import/export files aren't dropped in main directory

importCmd.mjs:

  • expanded functionality to support new updateResource()
  • expanded functionality to support updated createResource()
  • Added an outputDir so import files aren't dropped in main directory

exportCmd.mjs:

  • Added an outputDir so export files aren't dropped in main directory

Instructions/Limitations & FRs needed:

Instructions/Limitations:

  • Creating a resource:
    • A resource will be created if an existing Id is not found AND must have (a) name, (b) remoteNetworkLabel, and (c) addressValue specified.
      - serviceAccounts will not get updated as there is currently no argument available for resourceCreate mutation.
      - isActive will not get updated as there is currently no argument available for resourceCreate.
  • Updating a resource:
    • A resource will instead be updated if an existing Id is found AND (a) name, (b) remoteNetworkLabel, and (c) addressValue are specified.
      - serviceAccounts will not get updated as there is currently no argument available for resourceUpdate.

FRs needed:

  • resourceUpdate Mutation
    • needs serviceAccounts ([]) - or the new access{serviceAccounts, groupIds}
  • resourceCreate Mutation
    • needs isActive (boolean)
    • needs serviceAccounts ([]) - or goes off the new access{serviceAccounts, groupIds}

@gbern-tg gbern-tg changed the title Expand on createResource & updateResource functionality Bulk update/create Resources from Excel Dec 11, 2023
@gbern-tg gbern-tg marked this pull request as ready for review December 11, 2023 17:09
…ction, as this break the other functions. In the same updating the import usage to use the new order.
@chenbishop
Copy link
Contributor

@gbern-tg

Hi Grady, I made a commit to fix an issue where the createResource call in different places was not working because the order of the function argument was changed. Please let me know if you are happy with the changes?

I also tried to add the functionality of importing (creating and updating) security policy directly but this is require quite a bit of effort (though we can still change security policy by editing resource during the import), is this needed for your use-case ?

I ran the following tests:

  1. tg resource create, this is working now after the new commit
  2. tg export seems to be working ok
  3. tg import seems to be working ok
    a. tested resource update and create
    b. tested resource with updated security policy column change
  4. tg import on security policy does not work at the moment as mentioned previously
    1. we cannot use import to create or update the security policy directly
    2. can change policy of a resource through changing resource

Are there anything else you believe I should be testing in particular and could you let me know what have you tested already please?

Copy link
Contributor

@chenbishop chenbishop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved, merging into main.

@chenbishop chenbishop merged commit 797fb03 into main Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants